Generalized Watts-Strogatz Graph Experiments Output Visualization


In [3]:
#!/usr/bin/python
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from stats import parse_results, get_percentage, get_avg_per_seed, draw_pie, draw_bars, draw_bars_comparison, draw_avgs

Parse results


In [4]:
pr, eigen, bet = parse_results('test_genws.txt')

PageRank Seeds Percentage

How many times the "Top X" nodes from PageRank have led to the max infection


In [5]:
draw_pie(get_percentage(pr))


Avg adopters per seed comparison


In [6]:
draw_bars_comparison('Avg adopters per seeds', 'Avg adopters', np.array(get_avg_per_seed(pr)+[(0, np.mean(pr[:,1]))]))


Eigenvector Seeds Percentage

How many times the "Top X" nodes from Eigenvector have led to the max infection


In [7]:
draw_pie(get_percentage(eigen))


Avg adopters per seed comparison


In [8]:
draw_bars_comparison('Avg adopters per seeds', 'Avg adopters', np.array(get_avg_per_seed(eigen)+[(0, np.mean(eigen[:,1]))]))


Betweenness Seeds Percentage

How many times the "Top X" nodes from Betweenness have led to the max infection


In [9]:
draw_pie(get_percentage(bet))


Avg adopters per seed comparison


In [10]:
draw_bars_comparison('Avg adopters per seeds', 'Avg adopters', np.array(get_avg_per_seed(bet)+[(0, np.mean(bet[:,1]))]))


100 runs adopters comparison


In [11]:
draw_bars(np.sort(pr.view('i8,i8'), order=['f0'], axis=0).view(np.int),
         np.sort(eigen.view('i8,i8'), order=['f0'], axis=0).view(np.int),
         np.sort(bet.view('i8,i8'), order=['f0'], axis=0).view(np.int))


Centrality Measures Averages

PageRank avg adopters and seed


In [12]:
pr_mean = np.mean(pr[:,1])
pr_mean_seed = np.mean(pr[:,0])
print 'Avg Seed:',pr_mean_seed, 'Avg adopters:', pr_mean


Avg Seed: 97.85 Avg adopters: 175.92

Eigenv avg adopters and seed


In [13]:
eigen_mean = np.mean(eigen[:,1])
eigen_mean_seed = np.mean(eigen[:,0])
print 'Avg Seed:',eigen_mean_seed, 'Avg adopters:',eigen_mean


Avg Seed: 97.9 Avg adopters: 211.67

Betweenness avg adopters and seed


In [14]:
bet_mean = np.mean(bet[:,1])
bet_mean_seed = np.mean(bet[:,0])
print 'Avg Seed:',bet_mean_seed, 'Avg adopters:',bet_mean


Avg Seed: 98.0 Avg adopters: 299.76

In [15]:
draw_avgs([pr_mean, eigen_mean, bet_mean])